//
//  CategoryHome.swift
//  codelabs
//
//  Created by 雷雷 on 24/05/2025.
//

import SwiftUI

struct CategoryHome: View {
    @Environment(ModelData.self) var modelData
    
    
    var body: some View {
        List{
            modelData.features[0].image
                .resizable()
                .scaledToFill()
                .frame(height:200)
                .clipped()
                .listRowInsets(EdgeInsets())
            
            ForEach(modelData.categories.keys.sorted(),id:\.self){key in
                CategoryRow(categoryName: key, items: modelData.categories[key]!)
            }
            .listRowInsets(EdgeInsets())
        }
    }
}

#Preview {
    CategoryHome()
        .environment(ModelData())
        .navigationTitle("Feature")
}
